package 数组;

public class SolutionDemo04 {
    public int removeDuplicates(int[] nums) {
        int left = 1;
        for (int right = 1; right < nums.length; right++) {
            if (left < right && nums[right] == nums[left] && nums[right] != nums[left - 1]) {
                nums[++left] = nums[right];
            } else if (nums[left] < nums[right]) {
                nums[++left] = nums[right];
            }
        }
        return left + 1;
    }
}
